/**
 * Ingenius-Group S.A.S
 *
 * Project: SAU
 * File: StringFilter.java
 * Date: 10/03/2011
 */

package com.ingenius.sau.shared.util.filter;

/**
 * Class <strong>StringFilter</strong>
 * 
 * @author Jesus David
 * @version 0.1
 */
public class StringFilter implements Filter {

	protected Comparison comparison;

	protected String fieldName;

	protected String value;

	public StringFilter() {
	}

	public StringFilter(Comparison comparison, String fieldName, String value) {
		setComparison(comparison);
		setFieldName(fieldName);
		setValue(value);
	}

	public Comparison getComparison() {
		return comparison;
	}

	public void setComparison(Comparison comparison) {
		this.comparison = comparison;
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public boolean isValid() {
		if (comparison != null && fieldName != null && value != null) {

			if (getFieldName().isEmpty()) {
				return false;
			}
			if (getValue() instanceof String && ((String) getValue()).isEmpty()) {
				return false;
			}
			return true;
		}
		return false;
	}

}
